import com.sun.javafx.binding.StringFormatter;
import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-12
 * Time: 14:12
 */
//继承
class Animal{
    public String name;
    public int age;

    public Animal(){

    }
    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void eat(){
        System.out.println(name+"吃饭!");
    }
}
class  Dog extends Animal{
    public float weight;

    //子类的构造方法
    public Dog(){

    }
    public Dog(String name,int age,float weight){

        super(name, age);
        this.name = name;
        this.age = age;

        this.weight = weight;
    }
    public void bark(){
        System.out.println(name+"正在汪汪汪!");
    }

    @Override//对象的调用 注解  注释+解释
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                '}';
    }
}
class Cat extends Animal{
    public void miaomiao(){
        System.out.println(name+"正在喵喵喵!");
    }
}
//class  Dog{
//    public String name;
//    public int age;
//    public float weight;
//    public void eat(){
//        System.out.println(name+"吃饭!");
//    }
//    public void bark(){
//        System.out.println(name+"正在汪汪汪!");
//    }
//}
//class cat{
//    public String name;
//    public int age;
//
//    public void eat(){
//        System.out.println(name+"吃饭!");
//    }
//    public void bark(){
//        System.out.println(name+"正在喵喵喵!");
//    }
//}
public class TestDemo {
    public static void main(String[] args) {

    }
    //继承 inherit
    public static void main2(String[] args) {
        Cat cat = new Cat();
        cat.name = "mimi";
        cat.age = 1;
        cat.miaomiao();
        cat.eat();
    }
    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.name = "狗子";
        dog.age = 2;
        dog.weight = 20;
        dog.bark();
        dog.eat();
        System.out.println(dog);
    }
}
